package drds.configuration.db.xml_mapping.configuration;

import lombok.Getter;
import lombok.Setter;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;

/**
 * 如果parameterClass为空,则默认是MAP字段映射
 */
public class ParameterMap {
    @Setter
    @Getter
    private String id;
    @Setter
    @Getter
    private Class<?> parameterClass;
    @Setter
    @Getter
    private List<ParameterMapping> parameterMappingList = new ArrayList<ParameterMapping>();
    //
    @Setter
    @Getter
    private Set<String> columnNameSet = new HashSet<>();
    @Setter
    @Getter
    private Set<String> propertyNameSet = new HashSet<>();
    @Setter
    @Getter
    private ConcurrentHashMap propertyNameToColumnNameMap = new ConcurrentHashMap<String, String>();
    @Setter
    @Getter
    private ConcurrentHashMap columnNameMapToPropertyNameMap = new ConcurrentHashMap<String, String>();

    public List<ParameterMapping> copyParameterMappingList() {
        List<ParameterMapping> parameterMappingList = new ArrayList<ParameterMapping>();
        if (this.parameterMappingList != null) {
            for (ParameterMapping parameterMapping : this.parameterMappingList) {
                parameterMappingList.add(parameterMapping.copy());
            }
        }
        return parameterMappingList;
    }
}
